aboutsummaryrefslogtreecommitdiff
path: root/packages/astro/test/fixtures/content-layer/src/pages/spacecraft/[slug].astro
diff options
context:
space:
mode:
Diffstat (limited to 'packages/astro/test/fixtures/content-layer/src/pages/spacecraft/[slug].astro')
-rw-r--r--packages/astro/test/fixtures/content-layer/src/pages/spacecraft/[slug].astro35
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/astro/test/fixtures/content-layer/src/pages/spacecraft/[slug].astro b/packages/astro/test/fixtures/content-layer/src/pages/spacecraft/[slug].astro
new file mode 100644
index 000000000..80314606f
--- /dev/null
+++ b/packages/astro/test/fixtures/content-layer/src/pages/spacecraft/[slug].astro
@@ -0,0 +1,35 @@
+---
+import type { GetStaticPaths } from "astro";
+import { getCollection, getEntry, render } from "astro:content"
+import { Image } from "astro:assets"
+
+export const getStaticPaths = (async () => {
+ const collection = await getCollection("spacecraft");
+ if(!collection) return []
+ return collection.map((craft) => ({
+ params: {
+ slug: `/${craft.id}`
+ },
+ props: {
+ craft
+ }
+ }));
+}) satisfies GetStaticPaths;
+
+
+
+
+const { craft } = Astro.props as any
+
+let cat = craft.data.cat ? await getEntry(craft.data.cat) : undefined
+const { Content, headings } = await render(craft)
+
+---
+<meta charset="utf-8">
+<h1>{craft.data.title}</h1>
+<ul>
+{headings.map((heading) => <li><a href={`#${heading.slug}`}>{heading.text}</a></li>)}
+</ul>
+{cat? <p>🐈: {cat.data.breed}</p> : undefined}
+{craft.data.heroImage ? <Image src={craft.data.heroImage} alt={craft.data.title} width="100" height="100"/> : undefined}
+<Content />